/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-1-15 下午6:47 Created by dwzhang
 */
package com.jade.modules.cms;

import java.util.List;
import javax.persistence.*;

/**
 * 内容分类，栏目、专题都是用分类来进行管理。应用系统可以设定一个固定的PARENT ID，旗下所有的子分类即为专题。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-1-15 下午6:47
 */
//@Entity
//@Table (name = "MODULE_CMS_CATEGORY")
public class CmsCategory extends CmsEntity
{
    public static final int ROOT_ID = 0;
    public static final int STATUS_NORMAL = 0;
    public static final int STATUS_PAUSED = 1;

    //分类ID
    @Id
    @GeneratedValue (generator = "MODULE_SEQ_CMS_CATEGORY")
    @SequenceGenerator (name = "MODULE_SEQ_CMS_CATEGORY", sequenceName = "MODULE_SEQ_CMS_CATEGORY")
    private long id;
    //上级分类id
    @Column (name = "parent_id", nullable = false)
    private long parentId = ROOT_ID;
    //分类类型,根据具体业务使用
    @Column (name = "type", length = 16)
    private String type;
    //分类代码
    @Column (name = "category_code")
    private String categoryCode;
    //分类的外部链接，根据业务需要使用
    @Column (name = "url", length = 128)
    private String url;
    //分类模版，为0继承上一级。
    @Column (name = "template")
    private long templateId = 0;
    //评论标记 0 - 不允许评论 1 - 允许评论 2 - 登录评论 9 - 依据上级分类设置
    @Column (name = "comment_flag")
    private int commentFlag = CmsConstants.FLAG_INHERIT;
    //内容列表图片标志 0 - 不允许图片 1 - 允许图片 9 - 依据上级分类设置
    @Column (name = "title_image_flag")
    private int titleImageFlag = CmsConstants.FLAG_INHERIT;
    //缺省的内容列表图片
    @Column (name = "default_title_image")
    private String defaultTitleImage;
    //分享标志 0 - 不允许分享 1 - 允许分享 9 - 依据上级分类设置
    @Column (name = "share_flag")
    private int shareFlag = CmsConstants.FLAG_INHERIT;
    //评分标志 0 - 不允许评分 1 - 允许评分 9 - 依据上级分类设置
    @Column (name = "score_flag")
    private int scoreFlag = CmsConstants.FLAG_INHERIT;
    //点赞标志 0 - 不允许点赞 1 - 允许点赞 9 - 依据上级分类设置
    @Column (name = "like_flag")
    private int likeFlag = CmsConstants.FLAG_INHERIT;
    @Transient
    private List<CmsCategory> children;

    public CmsCategory()
    {
        setStatus(STATUS_NORMAL);
    }

    public long getId()
    {
        return id;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public long getParentId()
    {
        return parentId;
    }

    public void setParentId(long parentId)
    {
        this.parentId = parentId;
    }

    public int getSortCode()
    {
        return sortCode;
    }

    public void setSortCode(int sortCode)
    {
        this.sortCode = sortCode;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public String getCategoryCode()
    {
        return categoryCode;
    }

    public void setCategoryCode(String categoryCode)
    {
        this.categoryCode = categoryCode;
    }

    public String getUrl()
    {
        return url;
    }

    public void setUrl(String url)
    {
        this.url = url;
    }

    public long getTemplateId()
    {
        return templateId;
    }

    public void setTemplateId(long templateId)
    {
        this.templateId = templateId;
    }

    public int getCommentFlag()
    {
        return commentFlag;
    }

    public void setCommentFlag(int commentFlag)
    {
        this.commentFlag = commentFlag;
    }

    public int getTitleImageFlag()
    {
        return titleImageFlag;
    }

    public void setTitleImageFlag(int titleImageFlag)
    {
        this.titleImageFlag = titleImageFlag;
    }

    public String getDefaultTitleImage()
    {
        return defaultTitleImage;
    }

    public void setDefaultTitleImage(String defaultTitleImage)
    {
        this.defaultTitleImage = defaultTitleImage;
    }

    public int getShareFlag()
    {
        return shareFlag;
    }

    public void setShareFlag(int shareFlag)
    {
        this.shareFlag = shareFlag;
    }

    public int getScoreFlag()
    {
        return scoreFlag;
    }

    public void setScoreFlag(int scoreFlag)
    {
        this.scoreFlag = scoreFlag;
    }

    public int getLikeFlag()
    {
        return likeFlag;
    }

    public void setLikeFlag(int likeFlag)
    {
        this.likeFlag = likeFlag;
    }

    public List<CmsCategory> getChildren()
    {
        return children;
    }

    public void setChildren(List<CmsCategory> children)
    {
        this.children = children;
    }
}
